package com.kerbores.meeting.biz.impl;

import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;

import com.kerbores.meeting.biz.IDepartmentService;
import com.kerbores.meeting.dao.IDepartmentDao;
import com.kerbores.meeting.domain.Department;
import com.kerbores.utils.web.pager.Pager;

/**
 * @author Kerbores
 *
 *         Create At 2015年1月16日 下午3:08:23
 */
@IocBean(name = "departmentService")
public class DepartmentServiceImpl implements IDepartmentService {

	@Inject
	private IDepartmentDao departmentDao;

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.kerbores.meeting.biz.IDepartmentService#findByPage(int, int)
	 */
	@Override
	public Pager<Department> findByPage(int page, int pageSize) {
		Pager<Department> pager = new Pager<Department>(pageSize, page);
		pager.setCount(departmentDao.countAll());
		pager.setEntities(departmentDao.searchByPage(null, page, pageSize));
		return pager;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.kerbores.meeting.biz.IDepartmentService#save(com.kerbores.meeting
	 * .domain.Department)
	 */
	@Override
	public boolean save(Department department) {
		return departmentDao.save(department) != null;
	}

}
